#ifndef GRAPH_H
#define GRAPH_H

#include <QtCore>

#include "igraph.h"

namespace sk {

class DepthFirstSearch;

class CGraph : public ICGraph {
public:
    friend class DepthFirstSearch;

    CGraph() : edgesCount(0) {}

    void init(int verticesCount) {
        vertices.clear();

        vertices.append(QList<int>());
        for (int i = 0; i < verticesCount; i++) {
            vertices.append(QList<int>());
        }
    }

    void addEdge(int from, int to) {
        vertices[from].append(to);
        edgesCount++;
    }

    const QList<int>& getAdjanancies(int v) {
        return vertices.at(v);
    }

    int getEdgesCount() {
        return edgesCount;
    }

    int getVerticesCount() {
       return vertices.size() - 1;
    }

private:
    int edgesCount;
    QList< QList<int> > vertices;
};

}

#endif // GRAPH_H
